// 根路径优化
axios.defaults.baseURL='http://ajax-api.itheima.net'
axios.interceptors.response.use(response => {
// Do something before response is sent
// console.log(response);
return response;
},error => {
  if(error.response.status===401)location.href='./login.html'
// Do something with response error
return Promise.reject(error);
});
$('#logout').on('click',function(){
  localStorage.removeItem('heitoken')
  localStorage.removeItem('ename')
  location.href='./login.html'
})

axios.interceptors.request.use(config => {
// Do something before request is sent
// console.log(config);
config.headers.Authorization=localStorage.getItem('heitoken')
return config;
},error => {
// Do something with request error
return Promise.reject(error);
});


// bootstrap轻提示
const toastBox = document.querySelector('#myToast')
const toast = new bootstrap.Toast(toastBox, {
  animation: true, // 开启过渡动画
  autohide: true, // 开启自动隐藏
  delay: 3000, // 3000ms后自动隐藏
  
})
const tip = (msg) => {
  toastBox.querySelector('.toast-body').innerHTML = msg
  toast.show()
}
function getName(){
  $('#ename').html(localStorage.getItem('ename'))
}
getName()